package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.model.Page;
import org.springframework.stereotype.Repository;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.ReportTrendsDao;
import com.baichang.taoshunda.entity.ReportTrends;

@Repository
public class ReportTrendsDaoImpl extends BaseDaoImpl<ReportTrends> implements ReportTrendsDao {
    /**
     * 查询举报的互动信息
     *
     * @param nowPage
     * @param pageSize
     * @param userName
     * @return
     */
    @Override
    public Page queryReportTrends(int nowPage, int pageSize, String userName) {
        String sql = "SELECT td.*,rt.created AS createdTime,te.type_name typeName,tu.nick_name AS userName,tb.buss_name AS busName,rt.id AS reportId FROM t_trends td " +
                "INNER JOIN t_report_trends rt ON rt.trends_id=td.id LEFT JOIN t_trends_user tt ON rt.user_id=tt.id " +
                "LEFT JOIN t_user tu ON tu.id=tt.user_id " +
                "LEFT JOIN t_bussiness tb ON tb.id=tt.bus_id LEFT JOIN t_trends_type te ON td.type_id=te.id WHERE td.status=1";
        if (!userName.equals("")) {
            sql += "AND tu.nick_name LIKE'%" + userName + "%' ";
        }
        sql += " ORDER BY td.release_time DESC";
        return pageForMapList(sql, nowPage, pageSize);
    }
}